1/****************************************************************
    2 *                                                              *
    3 * Event Recognition for Public Space Surveillance (PSS/CAVIAR)	* 
    4 *                                                              *
    5 *                                                              *
    6 * Implemented in YAP						*
    7 * Alexander Artikis						*
    8 *								*
    9 ****************************************************************/
   10
   11
   12/********************************************************************** DECLARATIONS *******************************************************************************
   13 -Declare the entities of the event description: events, simple and statically determined fluents.
   14 -For each entity state if it is input or output (simple fluents are by definition output entities).
   15 -For each input/output entity state its index.
   16 -For input entities/statically determined fluents state whether the intervals will be collected into a list or built from time-points.
   17 -Declare the groundings of the fluents and output entities/events.
   18 -Declare the order of caching of output entities.
   19 *******************************************************************************************************************************************************************/
   20
   21
   22event(appear(_)).					inputEntity(appear(_)).				index(appear(Id), 			Id).
   23event(disappear(_)).					inputEntity(disappear(_)).			index(disappear(Id), 			Id).
   24	
   25simpleFluent(person(_)=true).    			outputEntity(person(_)=true).			index(person(Id)=true, 			Id).
   26simpleFluent(leaving_object(_,_)=true).			outputEntity(leaving_object(_,_)=true).		index(leaving_object(Id,_)=true,	Id).
   27simpleFluent(meeting(_,_)=true).			outputEntity(meeting(_,_)=true).		index(meeting(Id,_)=true, 		Id).
   28
   29sDFluent(walking(_)=true).				inputEntity(walking(_)=true).			index(walking(Id)=true, 		Id).
   30sDFluent(active(_)=true).				inputEntity(active(_)=true).			index(active(Id)=true, 			Id).
   31sDFluent(inactive(_)=true).				inputEntity(inactive(_)=true).			index(inactive(Id)=true, 		Id).
   32sDFluent(running(_)=true).				inputEntity(running(_)=true).			index(running(Id)=true, 		Id).
   33sDFluent(abrupt(_)=true).				inputEntity(abrupt(_)=true).			index(abrupt(Id)=true, 			Id).
   34sDFluent(distance(_,_,_)=true).				internalEntity(distance(_,_,_)=true).		index(distance(Id,_,_)=true, 		Id).
   35sDFluent(close(_,_,_)=true).				outputEntity(close(_,_,_)=true).		index(close(Id,_,_)=true,		Id).
   36sDFluent(close(_,_,_)=false).				outputEntity(close(_,_,_)=false).		index(close(Id,_,_)=false,		Id).
   37sDFluent(closeSymmetric(_,_,_)=true). 			outputEntity(closeSymmetric(_,_,_)=true).	index(closeSymmetric(Id,_,_)=true, 	Id).
   38sDFluent(activeOrInactivePerson(_)=true).		outputEntity(activeOrInactivePerson(_)=true).	index(activeOrInactivePerson(Id)=true,	Id).  		
   39sDFluent(greeting1(_,_)=true).	  			outputEntity(greeting1(_,_)=true).		index(greeting1(Id,_)=true, 		Id).	
   40sDFluent(greeting2(_,_)=true).  			outputEntity(greeting2(_,_)=true).		index(greeting2(Id,_)=true, 		Id).
   41sDFluent(moving(_,_)=true).				outputEntity(moving(_,_)=true).			index(moving(Id,_)=true, 		Id). 
   42sDFluent(fighting(_,_)=true). 				outputEntity(fighting(_,_)=true).		index(fighting(Id,_)=true, 		Id). 
   43
   44
   45% for input entities/statically determined fluents state whether 
   46% the intervals will be collected into a list or built from given time-points
   47
   48buildFromPoints(walking(_)=true).
   49buildFromPoints(active(_)=true).
   50buildFromPoints(inactive(_)=true).
   51buildFromPoints(running(_)=true).
   52buildFromPoints(abrupt(_)=true).
   53
   54% define the groundings of the fluents and output entities/events
   55
   56grounding(close(P1,P2,24)=true) :-			id_pair(P1, P2).
   57grounding(close(P1,P2,25)=true) :-			id_pair(P1, P2).
   58grounding(close(P1,P2,30)=true) :-			id_pair(P1, P2).
   59grounding(close(P1,P2,34)=true) :-			id_pair(P1, P2).
   60% we are only interesting in caching close=false with respect to the 34 threshold
   61% we don't need any other thresholds for this fluent in the CAVIAR event description
   62grounding(close(P1,P2,34)=false) :-			id_pair(P1, P2).
   63% similarly we are only interesting in caching closeSymmetric=true with respect to the 30 threshold
   64grounding(closeSymmetric(P1,P2,30)=true) :-		id_pair(P1, P2).
   65grounding(walking(P)=true) :- 				list_of_ids(P). 
   66grounding(active(P)=true) :- 				list_of_ids(P). 
   67grounding(inactive(P)=true) :- 				list_of_ids(P). 
   68grounding(abrupt(P)=true) :- 				list_of_ids(P). 
   69grounding(running(P)=true) :- 				list_of_ids(P). 
   70grounding(person(P)=true) :- 				list_of_ids(P). 
   71grounding(activeOrInactivePerson(P)=true) :- 		list_of_ids(P). 
   72grounding(greeting1(P1,P2)=true) :- 			id_pair(P1, P2).
   73grounding(greeting2(P1,P2)=true) :- 			id_pair(P1, P2).
   74grounding(leaving_object(Person,Object)=true) :- 	id_pair(Person, Object).
   75grounding(leaving_object(Person,Object)=true) :- 	symmetric_id_pair(Person, Object). 
   76grounding(meeting(P1,P2)=true) :- 			id_pair(P1, P2).
   77grounding(moving(P1,P2)=true) :- 			id_pair(P1, P2).
   78grounding(fighting(P1,P2)=true) :- 			id_pair(P1, P2).
   79
   80% cachingOrder should be defined for all output entities
   81
   82cachingOrder(close(_,_,_)=true).
   83cachingOrder(close(_,_,_)=false).
   84cachingOrder(closeSymmetric(_,_,_)=true).
   85cachingOrder(person(_)=true). 
   86cachingOrder(activeOrInactivePerson(_)=true). 
   87cachingOrder(greeting1(_,_)=true).
   88cachingOrder(greeting2(_,_)=true).
   89cachingOrder(leaving_object(_,_)=true). 
   90cachingOrder(meeting(_,_)=true).	
   91cachingOrder(moving(_,_)=true).
   92cachingOrder(fighting(_,_)=true)